﻿// <copyright file="AddPaymentKind.xaml.cs" company="company"> 
// (C) 2010 . All rights reserved
// </copyright>
// <author>Lukasz Bartczak</author>

namespace SecretaryAppNav.Views
{
    using System;
    using System.Windows.Controls;
    using SecretaryAppNav.ClientWcfService;

    /// <summary>
    /// AddPaymentKind partial class
    /// </summary>
    public partial class AddPaymentKind : Page
    {
        /// <summary>
        /// Service proxy.
        /// </summary>
        private Service1Client client = new Service1Client();

        /// <summary>
        /// Initializes a new instance of the <see cref="AddPaymentKind"/> class.
        /// </summary>
        public AddPaymentKind()
        {
            InitializeComponent();
            this.client.AddChildAndOpiekunCompleted += new System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(this.Client_AddChildAndOpiekunCompleted);
            this.client.GetPaymentFrequencyCompleted += new EventHandler<GetPaymentFrequencyCompletedEventArgs>(this.Client_GetPaymentFrequencyCompleted);
            this.client.GetPaymentFrequencyAsync();
            this.client.GetPaymentTypeCompleted += new EventHandler<GetPaymentTypeCompletedEventArgs>(this.Client_GetPaymentTypeCompleted);
            this.client.GetPaymentTypeAsync();
        }

        /// <summary>
        /// Handles the GetPaymentTypeCompleted event of the Client control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="SecretaryAppNav.ClientWcfService.GetPaymentTypeCompletedEventArgs"/> instance containing the event data.</param>
        private void Client_GetPaymentTypeCompleted(object sender, GetPaymentTypeCompletedEventArgs e)
        {
            this.cbPaymentType.DataContext = e.Result;
        }

        /// <summary>
        /// Handles the GetPaymentFrequencyCompleted event of the Client control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="SecretaryAppNav.ClientWcfService.GetPaymentFrequencyCompletedEventArgs"/> instance containing the event data.</param>
        private void Client_GetPaymentFrequencyCompleted(object sender, GetPaymentFrequencyCompletedEventArgs e)
        {
            this.cbPaymentFrequency.DataContext = e.Result;
        }

        /// <summary>
        /// Handles the AddChildAndOpiekunCompleted event of the Client control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.ComponentModel.AsyncCompletedEventArgs"/> instance containing the event data.</param>
        private void Client_AddChildAndOpiekunCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
        }

        /// <summary>
        /// Handles the Click event of the RadButtonAddPaymentKind control - add payment kind.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void RadButtonAddPaymentKind_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            this.client.AddPaymentKindAsync(this.cbPaymentType.SelectedValue.ToString(), this.cbPaymentFrequency.SelectedValue.ToString(), this.kindName.Value.ToString(), Convert.ToDouble(this.kindKwota.Value.ToString()));
            this.result.Content = "Dodano rodzaj opłaty!";
        }
    }
}
